SetImage
Sets an image to the current picture form.
Syntax
expression.SetImage(sImageSrc, nWidth, nHeight);
expression
- A variable that represents a ApiPictureForm class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
sImageSrc | Required | string | The image source where the image to be inserted should be taken from (currently, only internet URL or base64 encoded images are supported). | |
nWidth | Required | EMU | The image width in English measure units. | |
nHeight | Required | EMU | The image height in English measure units. |
Returns
boolean
Example
This example sets an image to the current picture form.
let doc = Api.GetDocument();
let pictureForm = Api.CreatePictureForm({"tip": "Upload your photo", "required": true, "placeholder": "Photo", "scaleFlag": "tooBig", "lockAspectRatio": true, "respectBorders": false, "shiftX": 50, "shiftY": 50});
pictureForm.SetImage("https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);